package com.chanzany.memento.improve;

/**
 * @Author ChanZany
 * @Date 2021/10/19 19:14
 * @Version 1.0
 * //发起人原型
 */
public class OriginatorPrototype implements Cloneable {
    private String state;
    public void setState(String state){
        this.state = state;
    }

    public String getState() {
        return state;
    }
    public OriginatorPrototype createMemento()  {
        return this.clone();
    }
    public void restoreMemento(OriginatorPrototype opt){
        this.state = opt.getState();
    }
    public OriginatorPrototype clone(){
        try {
            return (OriginatorPrototype) super.clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return null;
    }
}
